<%@ Page Title="Sys_Config Item" Language="C#" AutoEventWireup="true" CodeBehind="Sys_ConfigItem.aspx.cs" Inherits="Youz.CreditRepay.Manage.Sys_ConfigItem" %>

<script>
    

    var requireJS = [
        //"assets/js/jquery.form.js"
    ];
    loadJS(requireJS);
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2><i class="fa fa-edit"></i><%: R(LanguageModule.Sys_Config, "Sys_Config", "Sys_Config") %></h2>
            </div>
            <div class="panel-body">
                <form id="frm" class="form-horizontal" method="post" enctype="multipart/form-data" action="Sys/Handlers/Sys_ConfigHandler.ashx?type=save">
                    <input id="ISConfigKey" name="ISConfigKey" type="hidden" value="<%= WebHelper.Get("ConfigKey")==""?"add":"update" %>" />
                    <div class="form-group">
                        <label class="control-label" for="RoleDesc"><%: R(LanguageModule.FE_Goods, "ConfigKey", "配置Key") %></label>
                        <div class="controls">
                            <input type="text" id="ConfigKey" name="ConfigKey" maxlength="80" class="form-control" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="RoleDesc"><%: R(LanguageModule.Sys_Config, "ConfigValue", "配置Value") %></label>
                        <div class="controls">
                            <input type="text" id="ConfigValue" name="ConfigValue" maxlength="800" class="form-control required" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="RoleDesc"><%: R(LanguageModule.Sys_Config, "ConfigType", "配置分类") %></label>
                        <div class="controls">
                            <input type="text" id="ConfigType" name="ConfigType" maxlength="50" class="form-control required" />
                        </div>
                    </div>
                    <%--                    <div class="form-group">
                        <label class="control-label" for="RoleDesc"><%: R(LanguageModule.M_Common, "Status", "状态") %></label>
                        <div class="controls">
                            <select name="Status" id="Status" class="form-control required">
                                <option value="1" >启用</option>
                                <option value="2">禁用</option>
                            </select>
                        </div>
                    </div>--%>
                    <div class="form-group">
                        <label class="control-label" for="RoleDesc"><%: R(LanguageModule.Sys_Config, "Memo", "备注") %></label>
                        <div class="controls">
                            <textarea id="Memo" name="Memo" rows="3" maxlength="100" class="form-control"></textarea>
                        </div>
                    </div>
                    <%--                    <div class="form-group">
                        <label class="control-label" for="RoleDesc"><%: R(LanguageModule.Sys_Config, "IsModify", "是否可修改") %></label>
                        <div class="controls">
                            <label class="switch switch-info">
                                <input type="checkbox" id="IsModify" name="IsModify" class="switch-input"  checked="checked" /><span class="switch-label" data-on="On" data-off="Off"></span><span class="switch-handle"></span></label>
                        </div>
                    </div>--%>
                    <div class="alert alert-danger" style="display: none;">
                        <button type="button" class="close" data-dismiss="alert">×</button><strong>Oh snap!</strong><span class="content"></span>
                    </div>
                    <div class="form-actions">
                        <button class="btn btn-success" type="submit" id="btnSubmit"><%: R(LanguageModule.M_Common, "btnSubmit", "保存修改") %></button>
                        <button class="btn btn-default" type="button" id="btnCancel"><%: R(LanguageModule.M_Common, "btnCancel", "取消") %></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    var flag = false;

    function validate() {

        return $("#frm").valid();
    };

    function get() {
        $.post("Sys/Handlers/Sys_ConfigHandler.ashx?type=get", { ConfigKey: "<%= WebHelper.Get("ConfigKey") %>" }, function (data) {
            $('#frm').fill(data);
            $("#Memo").val(data.Memo);
            $("#Status").val(data.Status);
        }, 'json');
    }

    $(function () {
        $("#frm").validate({
            errorElement: "span"
        });

        get();
        if ("<%= WebHelper.Get("ConfigKey")%>" != "") {
            $("#ConfigKey").attr("readOnly", "readOnly");
        }
        $("#frm").ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, $form, options) {
                if (flag) {
                    return false;
                }
                else {
                    flag = true;
                    return true;
                }
            },
            success: function (data) {
                if (data.isSuccess) {
                    loadPage("Sys/Sys_ConfigList.aspx");
                }
                else {
                    $(".alert > .content").html(data.message);
                    $(".alert").show();
                }
                flag = false;
            }
        });

        $("#btnCancel").click(function () {
            loadPage("Sys/Sys_ConfigList.aspx");
        });
    });

</script>
